// @before-stub-for-debug-begin
#include <vector>
#include <string>
#include "commoncppproblem191.h"

using namespace std;
// @before-stub-for-debug-end

/*
 * @lc app=leetcode.cn id=191 lang=cpp
 *
 * [191] 位1的个数
 */

// @lc code=start
class Solution {
public:
    int hammingWeight(uint32_t n) {
        int res = 0;
        while (n) {
            n &= n - 1;
            res++;
        }
        return res;
    }
};
// @lc code=end

